﻿using System;
using System.Web.UI.WebControls;
using BLL;

public partial class ViewbyProduct_ViewHighFTest_HighFTestViewbyUIDDT : System.Web.UI.Page
{    
    private string var_userID
    {
        get { return ViewState["var_userID"].ToString(); }
        set { ViewState["var_userID"] = value; }
    }
    private DateTime var_starttime
    {
        get { return DateTime.Parse(ViewState["dt1"].ToString()); }
        set { ViewState["dt1"] = value; }
    }
    private DateTime var_stoptime
    {
        get { return DateTime.Parse(ViewState["dt2"].ToString()); }
        set { ViewState["dt2"] = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        var_userID = this.TextBox5.Text;
        var_starttime = DateTime.Parse(this.TextBox1.Value.Trim());
        var_stoptime = DateTime.Parse(this.TextBox2.Value.Trim());
        BindData();
    }

    protected void BindData()
    {
        Test t = new Test();
        this.GridView1.DataSource = t.GetHgihFTestbyUIDDT(var_userID, var_starttime, var_stoptime);
        this.GridView1.DataBind();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (GridView1.Rows[i].Cells[7].Text == "Fail")
                GridView1.Rows[i].Cells[7].ForeColor = System.Drawing.Color.Red;
        }
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        BindData();
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Session["productSN"] = GridView1.SelectedDataKey["ProductSN"].ToString();
        Session["testTime"] = Convert.ToDateTime(GridView1.SelectedDataKey["TestTime"]);
        Session["ProductTypeID"] = GridView1.SelectedDataKey["ProductTypeID"].ToString();
        Session["UserID"] = GridView1.SelectedDataKey["UserID"].ToString();
        Session["ENAID"] = GridView1.SelectedDataKey["ENAID"].ToString();
        Session["IsPass"] = GridView1.SelectedDataKey["IsPass"].ToString();

        Response.Redirect("~/ViewTest/ViewYourself/ViewHFTestItem.aspx");
    }
}
